﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.Decorator
{
    public abstract class Log
    {
        public virtual void Write(string log)
        {
            Console.WriteLine("将{0}在控制台输出", log);
        }
    }

    /// <summary>
    /// 数据库记录时，需要在控制台也输出
    /// </summary>
    public class DatabaseLog : Log
    {
        public override void Write(string log)
        {
            base.Write(log);
            Console.WriteLine("将{0}记录到数据库中", log);
        }
    }

    /// <summary>
    /// 文本模式时，不希望走父类的控制台输出
    /// </summary>
    public class TextFileLog : Log
    {
        public override void Write(string log)
        {
            Console.WriteLine("将{0}记录到文本文件中", log);
        }
    }
}
